<script setup lang="ts">
import { useAppStore } from '@/store';
import EventCollection from '@/pages/home/eventCollection';

interface IProps {
  item: BtnModelRelations;
  data: IBtnFormatsList[];
}

const props = defineProps<IProps>();
const store = useAppStore();

// 点击事件处理
const handlePress = (item: IBtnFormatsList) => {
  EventCollection.onPress(item, 2);
  store.$patch({ btnInformation: { ...item, moduleType: 2 } as IServerBtnListBtnList });
};

// 长按事件处理
const handleLongPress = (item: IBtnFormatsList) => {
  EventCollection.onLongPress(item);
  store.$patch({ btnInformation: { ...item, moduleType: 2 } as IServerBtnListBtnList });
};
</script>

<template>
  <view class="pos-relative">
    <swiper :indicator-dots="props.data.length > 1" indicator-active-color="#ffc300" :style="{ height: item.bannerHeight ? item.bannerHeight + 'px' : '125px' }">
      <swiper-item v-for="(item, index) in props.data" :key="index">
        <image class="w-full h-full" :src="item.value" mode="aspectFill" @click="handlePress(item)" @longpress="handleLongPress(item)" />
      </swiper-item>
    </swiper>
  </view>
</template>
